<?php
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/vendors/ckeditor/ckeditor.js', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/vendors/ckeditor/adapters/jquery.js', CClientScript::POS_HEAD);

Yii::app()->clientScript->registerScript('ckeditor', "
    var config = {
        toolbar: 
            [
                ['Source','-','Preview','Maximize', 'ShowBlocks'],
                ['Cut','Copy','Paste','PasteText',],
                ['Undo','Redo','-','SelectAll','RemoveFormat','-','Find','Replace'],
                ['BidiLtr', 'BidiRtl','-','SpellChecker', 'Scayt'],
                ['Image','Table','HorizontalRule','SpecialChar',],                  
                '/',          
                ['Font','FontSize'],
                ['TextColor','BGColor'],
                ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
                ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
                ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],              
                ['Link','Unlink'],                                    
            ],
        resize_dir: 'vertical',
    };
    
    $('textarea').ckeditor(function() {}, config);
    ", CClientScript::POS_READY);
?>

<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'note-form',
    'enableAjaxValidation' => false,
));
?>

<?php echo $form->errorSummary($model, null, null, array('class' => 'message error')); ?>

<p>
    <?php echo $form->labelEx($model, 'title'); ?> <br/>
    <?php echo $form->textField($model, 'title', array('class' => 'half', 'size' => 60, 'maxlength' => 255)); ?>
</p>

<p>
    <?php echo $form->labelEx($model, 'content'); ?>
    <?php echo $form->textArea($model, 'content', array('class' => 'full', 'rows' => 15, 'cols' => 75)); ?>
</p>

<p>
    <?php echo $form->labelEx($model, 'note_book_id'); ?>  <em>(optional)</em><br/>
    <?php echo $form->dropDownList($model, 'note_book_id', CHtml::listData(Yii::app()->user->model->noteBooks, 'id', 'name'), array('class' => 'half', 'prompt' => 'select notebook',)); ?>
</p>

<div class="action">
    <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'button button-gray')); ?>
</div>

<?php $this->endWidget(); ?>